def main():
    y_or_n = input("是否退出程序（退出请输入yes，否则输入no）？")
    while (y_or_n != "yes"):
        print("请输入以下个人信息，中间用空格隔开,性别请输入‘男’或‘女’，今日运动情况强度为轻微，轻度，中度，中高度，高强度")
        person_str = input("性别:体重（kg）：身高（cm）：年龄：今日运动情况：")#str函数将参数转换成字符串类型
        person = person_str.split(" ")#split()函数用于将字符串切片并转换为列表
        try:
            gender = person[0]
            weight = float(person[1])
            height = float(person[2])
            age = int(person[3])
            day = person[4]

            if gender == "男":
                bmr = 13.7 * weight + 5.0 * height - 6.8 * age + 66
                if day == "轻微":
                   daybmr = bmr * 1.2
                elif day == "轻度":
                     daybmr = bmr * 1.375
                elif day == "中度":
                     daybmr = bmr * 1.55
                elif day == "中高度":
                     daybmr = bmr * 1.725
                elif day == "高强度":
                     daybmr = bmr * 1.9
                else:
                     daybmr = 2
                if daybmr != 2:
                       print("您今日消耗能量为{}大卡", '{:.2f}'.format(daybmr))
                else:
                        print ("请按照说明对照自身输入活动强度")
            elif gender == "女":
                bmr = 9.6 * weight + 3.8 * height - 4.7 * age + 655
                if day == "轻微":
                   daybmr = bmr * 1.2
                elif day == "轻度":
                     daybmr = bmr * 1.375
                elif day == "中度":
                     daybmr = bmr * 1.55
                elif day == "中高度":
                     daybmr = bmr * 1.725
                elif day == "高强度":
                     daybmr = bmr * 1.9
                else:
                     daybmr = 2
                if daybmr != 2:
                       print("您今日消耗能量为{}大卡", '{:.2f}'.format(daybmr))
                else:
                        print ("请按照说明对照自身输入活动强度")
            else:
                bmr = -1
            if bmr != -1:
                print("您的性别为{}，体重为{}kg，身高为{}cm，年龄为{}岁，今日运动情况为{}".format(gender, weight, height, age, day))
                print("您的基础代谢率为{}大卡",'{:.2f}'.format(bmr))#format函数将值赋予前面的大括号且保留小数点后两位
            else:
                print("暂不支持该性别！")
        except ValueError:#形式不对
            print("请输入正确的个人信息！")
        except IndexError:#缺少信息
            print("请输入完整的个人信息！")
        except:
            print("系统有误！")
        y_or_n = input("是否退出程序（退出请输入yes）？")


if __name__ == "__main__":
    main()